Skip to content

dt-rust: Fix "Root" node detection #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged

dt-rust: Fix "Root" node detection #114

merged 1 commit into from
Jul 7, 2025

Conversation

d3zd3z
Copy link
Collaborator

@d3zd3z d3zd3z commented Jul 1, 2025

The labels node should occur only at the root node in the Rust-converted devicetree. However, when translating the format of the yaml file to use explicit types, the rule for this node didn't end up in an array. It isn't clear why this doesn't generate an error, but making it an explicit array does fix the issue.

Without this fix, the devicetree.rs that is generated has a duplicate copy of the labels module under every node. This fixes it to only occur at the top level.

Fixes: #113

The labels node should occur only at the root node in the Rust-converted
devicetree.  However, when translating the format of the yaml file to
use explicit types, the rule for this node didn't end up in an array.
It isn't clear why this doesn't generate an error, but making it an
explicit array does fix the issue.

Without this fix, the devicetree.rs that is generated has a duplicate
copy of the labels module under every node.  This fixes it to only occur
at the top level.

Fixes: #113

Signed-off-by: David Brown <[email protected]>
@d3zd3z d3zd3z requested review from teburd and cfriedt July 1, 2025 18:20
@teburd
Copy link

teburd commented Jul 1, 2025

Might need a little helper if you using serde and you want an empty array to error out https://stackoverflow.com/questions/75016452/serde-how-to-error-out-when-deserializing-empty-arrays

yaml is weird and issues like this might just be ignored 🤷 That's not unusual for yaml stuff.

@d3zd3z
Copy link
Collaborator Author

d3zd3z commented Jul 1, 2025

Might need a little helper if you using serde and you want an empty array to error out https://stackoverflow.com/questions/75016452/serde-how-to-error-out-when-deserializing-empty-arrays

yaml is weird and issues like this might just be ignored 🤷 That's not unusual for yaml stuff.

The thing is, I'm not sure an empty set of rules is exactly wrong. Well, maybe it is, as it would mean the actions should apply to every node. But, maybe there will be a future action where that makes sense. I'm not quite sure that the !Root means when just the value of the rules:, but clearly it does come out as an empty array.

@d3zd3z d3zd3z merged commit 2badee3 into main Jul 7, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

labels submodule is duplicated everywhere in devicetree.
3 participants